package com.zimmur.app.mocolink.background.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.zimmur.app.mocolink.background.common.ReturnJsonEntity;
import com.zimmur.app.mocolink.background.common.StatusCodeEnum;
import com.zimmur.app.mocolink.domain.common.Constant;
import com.zimmur.app.mocolink.domain.vo.GoodsTypeVo;
import com.zimmur.app.mocolink.service.IGoodsCategoryService;

@RestController
@RequestMapping("/restful/goodsType")
public class GoodsTypeController extends BaseController{
	
	@Autowired
	private IGoodsCategoryService goodsCategoryService;
	@RequestMapping("/queryGoodsType")
	public ReturnJsonEntity queryGoodsType(){
		ReturnJsonEntity entity = new ReturnJsonEntity();
		StatusCodeEnum codeEnum = StatusCodeEnum.CODE100000;
		List<GoodsTypeVo> list = goodsCategoryService.selectByGradeWithChild(Constant.Goods_Type_Grade_Top, null);
		if(list!=null){
			entity.setData(list);
			codeEnum = StatusCodeEnum.CODE000000;
		}
		entity.init(codeEnum);
		return entity;
	}
	@RequestMapping("/queryChildGoodsType")
	public ReturnJsonEntity queryChildGoodsType(){
		ReturnJsonEntity entity = new ReturnJsonEntity();
		StatusCodeEnum codeEnum = StatusCodeEnum.CODE100000;
		Integer parentId = getParam("typeId", 0); 
		List<GoodsTypeVo> list = goodsCategoryService.selectByGradeWithChild(Constant.Goods_Type_Grade_Third, parentId);
		if(list!=null){
			entity.setData(list);
			codeEnum = StatusCodeEnum.CODE000000;
		}
		entity.init(codeEnum);
		return entity;
	}
}
